<?php

namespace App\Http\Controllers;

use App\Models\Merchant;
use Illuminate\Http\Request;

class DemoController extends Controller
{
    public function index()
    {
        return view('demo');
    }

    public function store(Request $request)
    {
        $merchant = Merchant::find(1);
        $params = [
            'pid' => $merchant->client_id,
            'out_trade_no' => order_no(),
            'notify_url' => \request()->url(),
            'return_url' => \request()->url(),
            'name' => $request->input('name', '支付测试'),
            'money' => $request->input('money', '0.01'),
            'type' => $request->input('type', 'wxpay'),
        ];

        $params['sign'] = epay_sign($params, $merchant->client_secret);

        return redirect()->route('epay.submit', $params);
    }
}
